package com.example.netlib;



import object.p2pipcam.nativecaller.NativeCaller;
import android.os.Bundle;
import android.os.IBinder;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.util.Log;
import android.view.Menu;


public class MainActivity extends Activity {

//	private BridgeService mBridgeService;
//	private boolean isSearched;
//	private ServiceConnection mConn=new ServiceConnection() {
//		@Override
//		public void onServiceDisconnected(ComponentName name) {}
//		@Override
//		public void onServiceConnected(ComponentName name, IBinder service) {
//			mBridgeService = ((ControllerBinder)service).getBridgeService();
//		}
//	};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		//Native.StartSearch(this);
//        Intent intent=new Intent();
//        intent.setClass(this, BridgeService.class);
//        bindService(intent,mConn, Context.BIND_AUTO_CREATE);
		NativeCaller.StartSearch(MainActivity.this) ;
	}
    public void SearchResult(int cameraType, String strMac, String strName, String strDeviceID, String strIpAddr, int port){
    	Log.d("SearchResult", "SearchResult: " + strIpAddr + " " + port);
    	if (strDeviceID.length() == 0) {
			return;
		}
//    	if(addCameraActivity!=null){
//    		addCameraActivity.setSearchResultData(cameraType, strMac, strName, strDeviceID, strIpAddr, port);
//    	}
    	
    } 

	   
	    @SuppressWarnings("unused")
	    public void PPPPSnapshotNotify(String did, byte[] bImage, int len){
	    	Log.d("PPPPSnapshotNotify","did:"+did+" len:"+len);
	    }
		@SuppressWarnings("unused")
		public void PPPPMsgNotify(String did, int type, int param){
	    	Log.d("PPPPMsgNotify","PPPPMsgNotify  did:"+did+" type:"+type+" param:"+param);
	    	
	    	if(param == 2)
	    		NativeCaller.StartPPPPLivestream(MainActivity.this, "OBJ-001658-GXYCT", 3);
		}
		private void CallBack_PlaybackVideoData(byte[] videobuf, int h264Data, int len, int width,int height){
			Log.d("CallBack_PlaybackVideoData","playback  len:"+len+" width:"+width+" height:"+height);
//			if(playBackActivity!=null){
//				playBackActivity.CallBack_PlaybackVideoData(videobuf, h264Data, len, width, height);
//			}
		}
		
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		//getMenuInflater().inflate(R.menu.activity_main, menu);
		//startSearch(true);
		//NativeCaller.StartPPPPLivestream(MainActivity.this, "obj-001660-ujbur", 1);
		//NativeCaller.StartSearch(MainActivity.this) ;
//		NativeCaller.StopSearch();
		NativeCaller.PPPPInitial();
		NativeCaller.Init(MainActivity.this);
//		NativeCaller.Free();//
		//NativeCaller.PPPPSetCallbackContext(MainActivity.this);
		NativeCaller.StartPPPP("OBJ-001658-GXYCT", "admin", "");
		
		return true;
	}


}
